package cn.bon.websocket.pojo.bo;

import cn.bon.websocket.interfaces.MessagePusher;
import cn.bon.websocket.pojo.dto.MessageDTO;
import com.fasterxml.jackson.core.JsonProcessingException;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;

import java.util.List;

/**
 * @author: dronff
 * @description:
 * @CreateTime: 2023/12/12 15:55
 **/
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
public class WebsocketUserBO implements MessagePusher{
    /**
     * 用户名
     */
    private String username;

    /**
     * token
     */
    private String token;

    /**
     * 用户的权限
     */
    private List<GrantedAuthority> grantedAuthorities;

    /**
     * 用于推送消息
     */
    private MessagePusher pusher;

    @Override
    public void push(MessageDTO messageDTO) throws JsonProcessingException {
        pusher.push(messageDTO);
    }

    @Override
    public void shutDown() {
        pusher.shutDown();
    }

}
